# Github
covid19_confirmed_git <-"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv"
covid19_confirmed_git <- read_csv(url(covid19_confirmed_git))
# Worldometer
## Covid
codivid19_all <- "https://www.worldometers.info/coronavirus/"
main_table <- codivid19_all%>%
xml2::read_html()%>%
html_nodes(xpath='//*[@id="main_table_countries_today"]') %>%
html_table()
main_table <- as.data.frame(main_table)
## Filtering data for Balkan countries (plus Italy and Austria)
balkan <- filter(main_table,Country.Other == "Bosnia and Herzegovina" | Country.Other == "Italy" | Country.Other == "Croatia" | Country.Other == "Serbia" | Country.Other == "Montenegro" | Country.Other == "Slovenia" | Country.Other == "Austria" | Country.Other == "North Macedonia" | Country.Other == "Greece")
# Removing comma from numbers
balkan[c("TotalRecovered","TotalDeaths","TotalCases","NewCases","ActiveCases","Tot.Cases.1M.pop")] <- lapply(balkan[c("TotalRecovered","TotalDeaths","TotalCases","NewCases","ActiveCases","Tot.Cases.1M.pop")], function(x) gsub(",","",x))
# Turning columns to numeric
balkan[c("TotalRecovered","TotalDeaths","TotalCases","NewCases","ActiveCases","Tot.Cases.1M.pop")] <- lapply(balkan[c("TotalRecovered","TotalDeaths","TotalCases","NewCases","ActiveCases","Tot.Cases.1M.pop")], as.numeric)
The graph shows the number of confirmed cases by the last date shown.Updates daily at around 23:59 UTC.
# Curve of confirmed cases----
columns <- colnames(covid19_confirmed_git)[5:ncol(covid19_confirmed_git)]
final <-as.data.frame(pivot_longer(covid19_confirmed_git, cols = columns, names_to = "Year", values_to = "Confirmed"))
final$Year <- as.Date.character(final$Year,"%m/%d/%y")
colnames(final) <- c("Province","Country","Lat","Long","Year","Confirmed")
filter <- filter(final, Country == "Bosnia and Herzegovina" | Country == "Italy" | Country == "Croatia" | Country == "Serbia" | Country == "Slovenia" | Country == "Montenegro" | Country == "Austria" | Country == "North Macedonia" | Country == "Greece")
p <-ggplot(filter, aes(x = Year, y = Confirmed)) +
geom_line(aes(color = Country), size = 1) +
scale_color_brewer(palette="Set1")+
theme(legend.title = element_text(size = 6),legend.text = element_text(size = 6),
# Remove panel background
panel.background = element_blank(),
# Add axis line
axis.line = element_line(colour = "grey"),
axis.text.x = element_text(angle = 90))+
scale_y_log10(labels = comma)+
scale_x_date(date_labels = "%b-%d", date_breaks = "4 week")+
ylab("Confirmed cases")+
labs(caption="Data source: https://github.com/CSSEGISandData/COVID-19")
ggplotly(p)
```r
tot_cases_1m <- melt(balkan[,c(\Tot.Cases.1M.pop\,\Country.Other\)])
head(tot_cases_1m)
p<-ggplot(tot_cases_1m, aes(x=Country.Other,y=value,fill=Country.Other)) +
geom_bar(stat = \identity\)+
scale_fill_manual(name=\Country\,
values = c(\#E41A1C\,
\#377EB8\,
\#4DAF4A\,
\#984EA3\,
\#FF7F00\,
\#FFFF33\,
\#A65628\,
\#F781BF\,
\#999999\),
labels=c(\Austria\,
\Bosnia and Herzegovina\,
\Croatia\,
\Greece\,
\Italy\,
\Montenegro\,
\N.Macedonia\,
\Serbia\,
\Slovenia\))+
labs(x=\\,y=\Total Cases per 1M people\, title = \Total Cases per 1m people - Currently\)+
theme(legend.title = element_text(size = 8),
axis.text.x = element_blank(),
legend.text = element_text(size = 8),
panel.background = element_blank(),
axis.line = element_line(colour = \grey\))
ggplotly(p)
<!-- rnb-source-end -->
<!-- rnb-chunk-end -->
<!-- rnb-text-begin -->
## Deaths vs Recovered
The bar chart shows the total number of recovered people in comparison to the total number of death cases. Updates daily at around 23:59 UTC.
<!-- rnb-text-end -->
<!-- rnb-chunk-begin -->
<!-- rnb-source-begin eyJkYXRhIjoiYGBgclxuYGBgclxub3B0aW9ucyhzY2lwZW4gPSA5OTk5KVxucCA8LSBnZ3Bsb3QoYmFsa2FuKSArXG4gIGdlb21fc2VnbWVudCggYWVzKHg9Q291bnRyeS5PdGhlciwgeGVuZD1Db3VudHJ5Lk90aGVyLCB5PVRvdGFsUmVjb3ZlcmVkLCB5ZW5kPVRvdGFsRGVhdGhzKSwgY29sb3I9XFxncmV5XFwpICtcbiAgZ2VvbV9wb2ludCggYWVzKHg9Q291bnRyeS5PdGhlciwgeT1Ub3RhbFJlY292ZXJlZCksIGNvbG9yPXJnYigwLjIsMC43LDAuMSwwLjUpLCBzaXplPTMgKSArXG4gIGdlb21fcG9pbnQoIGFlcyh4PUNvdW50cnkuT3RoZXIsIHk9VG90YWxEZWF0aHMpLCBjb2xvcj1yZ2IoMC43LDAuMiwwLjEsMC41KSwgc2l6ZT0zICkgKyBjb29yZF9mbGlwKCkrXG4gIHNjYWxlX3lfbG9nMTAoKStcbiAgdGhlbWVfbWluaW1hbCgpICtcbiAgdGhlbWUoXG4gIGxlZ2VuZC5wb3NpdGlvbiA9IFxcbm9uZVxcLFxuICBwYW5lbC5iYWNrZ3JvdW5kID0gZWxlbWVudF9ibGFuaygpLFxuICBwYW5lbC5ncmlkID0gZWxlbWVudF9ibGFuaygpLFxuICBheGlzLmxpbmUgPSBlbGVtZW50X2xpbmUoY29sb3VyID0gXFxncmV5XFwpKSArXG4gICAgeGxhYihcXFxcKSArXG4gICAgeWxhYihcXE51bWJlciBvZiBjYXNlc1xcKStcbiAgICBnZ3RpdGxlKGxhYmVsID0gXFxEZWF0aCB2cyBSZWNvdmVyZWRcXClcbmdncGxvdGx5KHApXG5gYGBcbmBgYCJ9 -->
```r
```r
options(scipen = 9999)
p <- ggplot(balkan) +
geom_segment( aes(x=Country.Other, xend=Country.Other, y=TotalRecovered, yend=TotalDeaths), color=\grey\) +
geom_point( aes(x=Country.Other, y=TotalRecovered), color=rgb(0.2,0.7,0.1,0.5), size=3 ) +
geom_point( aes(x=Country.Other, y=TotalDeaths), color=rgb(0.7,0.2,0.1,0.5), size=3 ) + coord_flip()+
scale_y_log10()+
theme_minimal() +
theme(
legend.position = \none\,
panel.background = element_blank(),
panel.grid = element_blank(),
axis.line = element_line(colour = \grey\)) +
xlab(\\) +
ylab(\Number of cases\)+
ggtitle(label = \Death vs Recovered\)
ggplotly(p)
<!-- rnb-source-end -->
<!-- rnb-chunk-end -->
<!-- rnb-text-begin -->
## Active cases vs New cases
The bar chart shows the number of active cases in comparison to the number of new cases being constantly reported.
<!-- rnb-text-end -->
<!-- rnb-chunk-begin -->
<!-- rnb-source-begin eyJkYXRhIjoiYGBgclxuYGBgclxuIyBBY3RpdmUgY2FzZXMgdnMgTmV3IGNhc2VzXG5hY3RpdmVfYW5kX25ldyA8LSBtZWx0KGJhbGthblssYyhcXEFjdGl2ZUNhc2VzXFwsXFxOZXdDYXNlc1xcLFxcQ291bnRyeS5PdGhlclxcKV0pXG5wIDwtIGdncGxvdChhY3RpdmVfYW5kX25ldywgYWVzKHg9Q291bnRyeS5PdGhlciwgeT12YWx1ZSwgZmlsbD12YXJpYWJsZSkpICtcbiAgZ2VvbV9iYXIoc3RhdD0naWRlbnRpdHknLCBwb3NpdGlvbj0nZG9kZ2UnLCBjb2xvcj1cXGJsYWNrXFwgLGFlcyh0ZXh0PXBhc3RlKFxcQ291bnRyeTogXFwsQ291bnRyeS5PdGhlciwgXFxcXG5cXCwgdmFyaWFibGUsXFw6XFwsdmFsdWUsIHNlcD1cXFxcKSkpICtcbiAgc2NhbGVfZmlsbF9icmV3ZXIocGFsZXR0ZSA9IFxcUGFpcmVkXFwpK1xuICBzY2FsZV95X2NvbnRpbnVvdXMobGFiZWxzPWNvbW1hLCB0cmFucyA9IFxcbG9nMTBcXCkgK1xuICB5bGFiKFxcTnVtYmVyIG9mIGNhc2VzXFwpK1xuICB4bGFiKFxcXFwpK1xuICB0aGVtZV9taW5pbWFsKCkrXG4gIGxhYnModGl0bGUgPSBcXFxcLGZpbGw9XFxcXCkrXG4gIGNvb3JkX2ZsaXAoKVxuICBcbmdncGxvdGx5KHAsIHRvb2x0aXAgPSBcXHRleHRcXClcbmBgYFxuYGBgIn0= -->
```r
```r
# Active cases vs New cases
active_and_new <- melt(balkan[,c(\ActiveCases\,\NewCases\,\Country.Other\)])
p <- ggplot(active_and_new, aes(x=Country.Other, y=value, fill=variable)) +
geom_bar(stat='identity', position='dodge', color=\black\ ,aes(text=paste(\Country: \,Country.Other, \\n\, variable,\:\,value, sep=\\))) +
scale_fill_brewer(palette = \Paired\)+
scale_y_continuous(labels=comma, trans = \log10\) +
ylab(\Number of cases\)+
xlab(\\)+
theme_minimal()+
labs(title = \\,fill=\\)+
coord_flip()
ggplotly(p, tooltip = \text\)
```